package system

import (
	"gitee.com/micro-plat/sso/apiserver/api/modules/biz/system"
	"gitee.com/micro-plat/sso/apiserver/api/modules/const/field"
	"github.com/micro-plat/hydra"
)

//MemberHandler 获取系统信息处理服务
type SystemHandler struct {
	requiredFields []string
}

func NewSystemHandler() *SystemHandler {
	return &SystemHandler{
		requiredFields: []string{"ident"},
	}
}

//GetHandle  获取系统信息
func (u *SystemHandler) GetHandle(ctx hydra.IContext) (r interface{}) {

	ctx.Log().Info("--------获取系统数据--------")

	ctx.Log().Info("1.检查必须字段")
	if err := ctx.Request().Check(u.requiredFields...); err != nil {
		return err
	}

	ctx.Log().Info("2.获取系统信息")
	system, err := system.GetSystemInfo(ctx.Request().GetString(field.Ident))
	if err != nil {
		return err
	}
	return system
}
